const Base = require('./base')
const User = require('./User')
const House = require('./House')
const moment = require('moment')
class Review extends Base {
  get tableName () { return 'Review' }
  serialize () {
    const data = super.serialize()
    data.pics = data.pics.split(',')
    data.addTimeStr = moment(data.addTime).format('YYYY-MM-DD HH:mm')
    return data
  }
  user () {
    return this.hasOne(User, 'id', 'userId')
  }
  house () {
    return this.hasOne(House, 'id', 'houseId')
  }
}

module.exports = Review